/**
 * Index 模拟数据
 * 使用：
 * import IndexMock from './IndexMock'
 * Mock.mock("/admin/Index/menus", (option) => { return IndexMock.getMenus(option) })
 * Mock.mock("/admin/Index/main", (option) => { return IndexMock.getMainData(option) })
 */
class IndexMock {
    /**
     * 返回菜单列表数据
     * id, pid, title, controller, action, code, type, icon
     */
    getMenus(option) {

        // 教室管理
        // 教学监控
        // 教学联动
        // 运维管理
        // 资产管理
        // 数据统计
        // 用户管理
        // 系统设置

        //         运维管控首页	运维管控首页
        // ====教室管理	
        // 面板控制
        // 	教室详情
        // 	列表控制
        // 	物联信息
        // ===教学监控	
        // 4画面
        // 6画面

        //=== 教学联动	
        // 学期管理
        // 	节次管理
        // 	课表管理
        // 	任务管理

        // ====运维管理	
        // 智能巡检
        // 	故障报修
        // 	操作日志
        // 	刷卡日志
        // 	远程协助

        // ==资产管理	
        // 资产管理

        // ======数据统计	
        // 报表统计
        // 	数据大屏

        // ====用户管理	
        // 角色管理
        // 	用户管理
        // ====系统设置	
        // 教学楼管理
        // 	楼层管理
        // 	教室管理
        // 	数据维护
        // 	一卡通管理
        // 	门锁管理
        // 	开锁日志
        // 	中控编程
        // 	远程升级

        let param = this.parseOption(option);
        console.log('[IndexMock] 显示资源列表 param=', param, '&option=', option);
        let data = [
            {
                "id": 277,
                "path": "classroom",
                "name": "Classroom",
                "component": "Layout",
                "redirect": "",
                "meta": {
                    "title": "教室管理",
                    "icon": "",
                    "tagId": 0
                },
                "alwaysShow": false,
                "hidden": false,
                "children": [
                    {
                        "id": 272,
                        "path": "classroom",
                        "name": "Classroom",
                        "component": "views/classroom/IndexView",
                        "redirect": "",
                        "meta": {
                            "title": "教室管理",
                            "icon": "",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": [
                            
                        ]
                    }
                ]
            },
            {
                "id": 298,
                "path": "monitor",
                "name": "Monitor",
                "component": "Layout",
                "redirect": "",
                "meta": {
                    "title": "教学监控",
                    "icon": "",
                    "tagId": 0
                },
                "alwaysShow": false,
                "hidden": false,
                "children": [
                    {
                        "id": 299,
                        "path": "monitor",
                        "name": "Monitor",
                        "component": "views/monitor/IndexView",
                        "redirect": "",
                        "meta": {
                            "title": "教学监控",
                            "icon": "",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": [
                            
                        ]
                    }
                ]
            },
            {
                "id": 175,
                "path": "teaching",
                "name": "Teaching",
                "component": "Layout",
                "redirect": "",
                "meta": {
                    "title": "教学联动",
                    "icon": "calendar-alt",
                    "tagId": 0
                },
                "alwaysShow": false,
                "hidden": false,
                "children": [
                    {
                        "id": 176,
                        "path": "semester",
                        "name": "Semester",
                        "component": "",
                        "redirect": "",
                        "meta": {
                            "title": "学期管理",
                            "icon": "",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": []
                    },
                    {
                        "id": 177,
                        "path": "timetable",
                        "name": "Timetable",
                        "component": "",
                        "redirect": "",
                        "meta": {
                            "title": "节次管理",
                            "icon": "",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": []
                    },
                    {
                        "id": 178,
                        "path": "schedule",
                        "name": "Schedule",
                        "component": "",
                        "redirect": "",
                        "meta": {
                            "title": "课表管理",
                            "icon": "",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": []
                    },
                    {
                        "id": 221,
                        "path": "task",
                        "name": "Task",
                        "component": "Layout",
                        "redirect": "",
                        "meta": {
                            "title": "任务管理",
                            "icon": "calendar-plus",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": [
                            {
                                "id": 222,
                                "path": "taskPlan",
                                "name": "taskPlan",
                                "component": "",
                                "redirect": "",
                                "meta": {
                                    "title": "任务计划",
                                    "icon": "",
                                    "tagId": 0
                                },
                                "alwaysShow": false,
                                "hidden": false,
                                "children": []
                            },
                            {
                                "id": 226,
                                "path": "taskLog",
                                "name": "taskLog",
                                "component": "",
                                "redirect": "",
                                "meta": {
                                    "title": "任务日志",
                                    "icon": "",
                                    "tagId": 0
                                },
                                "alwaysShow": false,
                                "hidden": false,
                                "children": []
                            }
                        ]
                    }
                ]
            },
            {
                "id": 251,
                "path": "operation",
                "name": "Operation",
                "component": "Layout",
                "redirect": "",
                "meta": {
                    "title": "运维管理",
                    "icon": "ethernet",
                    "tagId": 0
                },
                "alwaysShow": false,
                "hidden": false,
                "children": [
                    {
                        "id": 243,
                        "path": "patrollog",
                        "name": "Patrollog",
                        "component": "views/operation/patrollog/IndexView",
                        "redirect": "",
                        "meta": {
                            "title": "智能巡检",
                            "icon": "",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": []
                    },
                    {
                        "id": 255,
                        "path": "workerorder",
                        "name": "Workerorder",
                        "component": "views/operation/workerorder/IndexView",
                        "redirect": "",
                        "meta": {
                            "title": "故障报修",
                            "icon": "envelope",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": []
                    },
                    {
                        "id": 183,
                        "path": "control",
                        "name": "Control",
                        "component": "views/operation/control/IndexView",
                        "redirect": "",
                        "meta": {
                            "title": "操作日志",
                            "icon": "",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": []
                    },
                    {
                        "id": 184,
                        "path": "cardlog",
                        "name": "Cardlog",
                        "component": "views/operation/cardlog/IndexView",
                        "redirect": "",
                        "meta": {
                            "title": "刷卡日志",
                            "icon": "",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": []
                    }
                ]
            },
            {
                "id": 250,
                "path": "equipment",
                "name": "Equipment",
                "component": "Layout",
                "redirect": "",
                "meta": {
                    "title": "资产管理",
                    "icon": "landmark",
                    "tagId": 0
                },
                "alwaysShow": false,
                "hidden": false,
                "children": [
                    {
                        "id": 254,
                        "path": "equipment",
                        "name": "Equipment",
                        "component": "views/equipment/IndexView",
                        "redirect": "",
                        "meta": {
                            "title": "资产管理",
                            "icon": "landmark",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": []
                    }
                ]
            },
            {
                "id": 266,
                "path": "report",
                "name": "Report",
                "component": "Layout",
                "redirect": "",
                "meta": {
                    "title": "数据统计",
                    "icon": "clone",
                    "tagId": 0
                },
                "alwaysShow": false,
                "hidden": false,
                "children": [
                    {
                        "id": 267,
                        "path": "report",
                        "name": "Report",
                        "component": "views/report/ReportView",
                        "redirect": "",
                        "meta": {
                            "title": "报表统计",
                            "icon": "clone",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": []
                    },
                    {
                        "id": 259,
                        "path": "bigscreen",
                        "name": "Bigscreen",
                        "component": "views/report/BigScreenView",
                        "redirect": "",
                        "meta": {
                            "title": "数据大屏",
                            "icon": "home",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": []
                    }
                ]
            },
            {
                "id": 8,
                "path": "user",
                "name": "User",
                "component": "Layout",
                "redirect": "",
                "meta": {
                    "title": "用户管理",
                    "icon": "cog",
                    "tagId": 0
                },
                "alwaysShow": false,
                "hidden": false,
                "children": [
                    {
                        "id": 9,
                        "path": "menu",
                        "name": "Menu",
                        "component": "views/user/menu/IndexView",
                        "redirect": "",
                        "meta": {
                            "title": "菜单管理",
                            "icon": "fa fa-television",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": []
                    },
                    {
                        "id": 12,
                        "path": "role",
                        "name": "Role",
                        "component": "views/user/role/IndexView",
                        "redirect": "",
                        "meta": {
                            "title": "角色管理",
                            "icon": "fa fa-users",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": []
                    },
                    {
                        "id": 257,
                        "path": "user",
                        "name": "User",
                        "component": "views/user/user/IndexView",
                        "redirect": "",
                        "meta": {
                            "title": "用户管理",
                            "icon": "",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": []
                    }
                ]
            },
            {
                "id": 168,
                "path": "system",
                "name": "System",
                "component": "Layout",
                "redirect": "",
                "meta": {
                    "title": "系统设置",
                    "icon": "tv",
                    "tagId": 0
                },
                "alwaysShow": false,
                "hidden": false,
                "children": [
                    {
                        "id": 300,
                        "path": "base",
                        "name": "Base",
                        "component": "Layout",
                        "redirect": "",
                        "meta": {
                            "title": "基础数据",
                            "icon": "tv",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": [
                            {
                                "id": 169,
                                "path": "building",
                                "name": "Building",
                                "component": "views/system/building/IndexView",
                                "redirect": "",
                                "meta": {
                                    "title": "教学楼管理",
                                    "icon": "",
                                    "tagId": 0
                                },
                                "alwaysShow": false,
                                "hidden": false,
                                "children": []
                            },
                            {
                                "id": 170,
                                "path": "floor",
                                "name": "Floor",
                                "component": "views/system/floor/IndexView",
                                "redirect": "",
                                "meta": {
                                    "title": "楼层管理",
                                    "icon": "",
                                    "tagId": 0
                                },
                                "alwaysShow": false,
                                "hidden": false,
                                "children": []
                            },
                            {
                                "id": 171,
                                "path": "room",
                                "name": "Room",
                                "component": "views/system/room/IndexView",
                                "redirect": "",
                                "meta": {
                                    "title": "教室管理",
                                    "icon": "",
                                    "tagId": 0
                                },
                                "alwaysShow": false,
                                "hidden": false,
                                "children": []
                            },
                            {
                                "id": 179,
                                "path": "init",
                                "name": "init",
                                "component": "views/system/InitSystemView",
                                "redirect": "",
                                "meta": {
                                    "title": "数据维护",
                                    "icon": "coffee",
                                    "tagId": 0
                                },
                                "alwaysShow": false,
                                "hidden": false,
                                "children": []
                            }
                        ]
                    },
                    {
                        "id": 244,
                        "path": "oneCard",
                        "name": "OneCard",
                        "component": "Layout",
                        "redirect": "",
                        "meta": {
                            "title": "一卡通管理",
                            "icon": "",
                            "tagId": 0
                        },
                        "alwaysShow": false,
                        "hidden": false,
                        "children": [
                            {
                                "id": 173,
                                "path": "iccard",
                                "name": "Iccard",
                                "component": "views/system/iccard/IndexView",
                                "redirect": "",
                                "meta": {
                                    "title": "一卡通管理",
                                    "icon": "",
                                    "tagId": 0
                                },
                                "alwaysShow": false,
                                "hidden": false,
                                "children": []
                            },
                            {
                                "id": 256,
                                "path": "smartlock",
                                "name": "Smartlock",
                                "component": "views/system/smartlock/IndexView",
                                "redirect": "",
                                "meta": {
                                    "title": "门锁管理",
                                    "icon": "",
                                    "tagId": 0
                                },
                                "alwaysShow": false,
                                "hidden": false,
                                "children": []
                            },
                            {
                                "id": 252,
                                "path": "smartlocklog",
                                "name": "Smartlocklog",
                                "component": "views/system/smartlocklog/IndexView",
                                "redirect": "",
                                "meta": {
                                    "title": "开锁日志",
                                    "icon": "",
                                    "tagId": 0
                                },
                                "alwaysShow": false,
                                "hidden": false,
                                "children": []
                            },
                            {
                                "id": 400,
                                "path": "program",
                                "name": "Program",
                                "component": "views/system/program/IndexView",
                                "redirect": "",
                                "meta": {
                                    "title": "中控编程",
                                    "icon": "",
                                    "tagId": 0
                                },
                                "alwaysShow": false,
                                "hidden": false,
                                "children": []
                            },
                            {
                                "id": 181,
                                "path": "upgrade",
                                "name": "Upgrade",
                                "component": "views/system/upgrade/IndexView",
                                "redirect": "",
                                "meta": {
                                    "title": "远程升级",
                                    "icon": "chalkboard-teacher",
                                    "tagId": 0
                                },
                                "alwaysShow": false,
                                "hidden": false,
                                "children": []
                            }
                        ]
                    }
                ]
            }
            
        ];
        return this.stdMessage(param._success, '没有数据', data);
    }

    /**
     * 返回运营统计数据
     */
    getMainData() {
        let param = this.parseOption(option);
        console.log('[通用模拟数据] 显示资源列表 param=', param, '&option=', option);
        let data = {
            stat_data: {
                zongzc: 354,
                benyuezc: 211,
                zuorizc: 4,
                jinrizc: 2,
                leijiczje: 1290,
                leijiczrs: 16,
                leijiczarpu: 81,
                benyueczje: 1090,
                benyueczrs: 12,
                benyueczarpu: 91,
                zuoriczje: 100,
                zuoriczrs: 1,
                zuoriczarpu: 100,
                jinriczje: 20,
                jinriczrs: 1,
                jinriczarpu: 20,
                zuorikh: 28,
                zuorixh: 498,
                jinrikh: 2,
                jinrixh: 13,
            },
        }
        data.yuefenzctj_data = {
            1: 2, 2: 2, 3: 16, 4: 9, 5: 2, 6: 2, 7: 0, 8: 44, 9: 20, 10: 37,
            11: 10, 12: 7, 13: 19, 14: 0, 15: 5, 16: 0, 17: 2, 18: 2, 19: 20, 20: 6,
            21: 4, 22: 2, 23: 0, 24: 0, 25: 0, 26: 0, 27: 0, 28: 0, 29: 0, 30: 0,
            31: 0,
        }
        data.yuefencztj_data = {
            1: 0, 2: 20, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 390, 9: 0, 10: 200,
            11: 20, 12: 20, 13: 0, 14: 20, 15: 0, 16: 0, 17: 0, 18: 0, 19: 0, 20: 300,
            21: 100, 22: 20, 23: 0, 24: 0, 25: 0, 26: 0, 27: 0, 28: 0, 29: 0, 30: 0,
            31: 0,
        }
        return this.stdMessage(param._success, '没有数据', data, status);
    }
    getDemoTjData() {
        let data = {};
        for (let i = 1; i <= 31; i++) {
            data[i] = Math.ceil(Math.random() * 1000);
        }
        return data;
    }

    getRandomStatus() {
        return Math.random() > 0.5 ? 1 : 0;
    }

    /**
     * 解析参数
     * option= {url:'/api/read?id=1', type:'GET', data:null}
     * @param {Object} option 
     * @returns
     */
    parseOption(option) {
        let param = {}
        if (option.url.indexOf('?') > -1) {
            new URLSearchParams(option.url.substring(option.url.indexOf('?') + 1)).forEach((v, k) => {
                param[k] = v;
            })
        }
        if (option.body) {
            if (option.body instanceof FormData) {
                option.body.forEach((v, k) => {
                    param[k] = v;
                })
            } else {
                param = JSON.parse(option.body);
            }
        }
        // 可以通过传参 _success 来控制返回消息的成功状态。默认返回成功消息。
        if (typeof (param._success) != 'boolean') {
            param._success = true; // Mock.mock('@boolean')
        }
        return param;
    }

    /**
     * 返回标准消息对象
     * @param {Boolean} success 
     * @param {String} message 
     * @param {Any} data 
     * @param {Number} code 
     * @returns 
     */
    stdMessage(success, message, data = '', code = 0) {
        return { success, message, data, code, }
    }
}

export default new IndexMock;